import request from '@/utils/request'

// 查询实有车辆信息列表
export function listVehicles(query) {
  return request({
    url: '/community/vehicles/list',
    method: 'get',
    params: query
  })
}

// 查询实有设备列表
export function listvehicles(query) {
  return request({
    url: '/community/vehicles/vehicleslist',
    method: 'get',
    params: query
  })
}

// 查询实有车辆信息详细
export function getVehicles(id) {
  return request({
    url: '/community/vehicles/' + id,
    method: 'get'
  })
}

// 新增实有车辆信息
export function addVehicles(data) {
  return request({
    url: '/community/vehicles',
    method: 'post',
    data: data
  })
}

// 修改实有车辆信息
export function updateVehicles(data) {
  return request({
    url: '/community/vehicles',
    method: 'put',
    data: data
  })
}

// 删除实有车辆信息
export function delVehicles(id) {
  return request({
    url: '/community/vehicles/' + id,
    method: 'delete'
  })
}

// 车辆一键布控
export function deployVehicles(data) {
  return request({
    url: '/community/vehicles/vehiclesAdd',
    method: 'post',
    data: data
  })
}

// 编辑车辆一键布控
export function deployUpdate(data) {
  return request({
    url: '/community/vehicles/deployUpdate',
    method: 'post',
    data: data
  })
}

/**
 * 功能：布控车辆信息查询
 * @param query
 * @returns {AxiosPromise<AxiosResponse<any>>}
 */
export function getMigration(data) {
  return request({
    url: '/community/vehicles/deployList',
    method: 'post',
    data: data, // 确保查询参数作为请求体发送
  })
}

/**
 * 功能：撤控
 */
export function updateStatus(id) {
  return request({
    url: '/community/vehicles/updateStatus?id='+id,
    method: 'get'
  })
}
/**
 * 功能：暂停
 */
export function stop(id) {
  return request({
    url: '/community/vehicles/stop?id='+id,
    method: 'get'
  })
}
/**
 * 功能：开始
 */
export function start(id) {
  return request({
    url: '/community/vehicles/start?id='+id,
    method: 'get'
  })
}

/**
 * 功能：暂停
 */
export function suspend(id) {
  return request({
    url: '/community/vehicles/suspend?id='+id,
    method: 'get'
  })
}

/**
 * 功能：删除
 */
export function deployDelete(id) {
  return request({
    url: '/community/vehicles/deployDelete?id='+id,
    method: 'get'
  })
}

// 导入车辆信息
export function handleImportVehicles(file) {
  const formData = new FormData();
  formData.append('file', file); // 将文件添加到 FormData 对象中

  return request({
    url: '/community/vehicles/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data' // 设置正确的 Content-Type
    }
  });
}


